package handlers;

import java.util.ArrayList;
import pausing.Pauseable;
//import skills.ActiveSkill;
import skills.Skill;
import stat.StatType;
import entity.Entity;

public class SkillHandler extends Pauseable {
	private Entity skillCaster = null;
	private ArrayList<Skill> skills;
	
	public SkillHandler(Entity skillCaster) {
		this.skillCaster = skillCaster;
		skills = skillCaster.getOccupation().getUpgradableSkillList();
		skills.addAll(skillCaster.getOccupation().getActiveSkillList());
	}
	
	public void useSkill(int skillIndex) {
		if(skillIndex >= skills.size())
			return;
		
		Skill skill = skills.get(skillIndex);
		if(skill != null && skillCaster.getStats().getStat(StatType.MP) > skill.getMPCost()) {
			skill.execute(skillCaster);
			skillCaster.getStats().update(StatType.MP, -1 * skill.getMPCost());
		//	System.out.println(skillCaster.getName() + " is facing: " + skillCaster.getDirection());
		//	System.out.println(skillCaster.getName() + ": " + skill.getInfluenceRadius().getDirection());
		}
	}
}
